<template>
	<view class="content">
		<scroll-view>
			<view class="ucenter-bg" @click="loginCheck">
				<image :src="loginInfo.hasLogin?loginInfo.user.photo:'/static/img/user2.png'" class="png" mode="widthFix"></image>
				<view class="text-xl">
					<text class="text-df">Hi,</text>{{loginInfo.hasLogin ? loginInfo.user.username : '您未登录'}}
				</view>
				<view class="margin-top-sm">
					<text></text>
				</view>
				<image src="/static/img/wave.gif" mode="scaleToFill" class="gif-wave"></image>
			</view>

			<view class="padding flex text-center text-grey bg-white shadow-warp">
				<view class="flex flex-sub flex-direction solid-right">
					<view class="text-xxl text-orange">{{visitTotal}}</view>
					<view class="margin-top-sm">
						<text class="cuIcon-attentionfill"></text>浏览</view>
				</view>
				<view class="flex flex-sub flex-direction solid-right">
					<view class="text-xxl text-blue">{{starCount}}</view>
					<view class="margin-top-sm">
						<text class="cuIcon-favorfill"></text>关注</view>
				</view>
				<view class="flex flex-sub flex-direction">
					<view class="text-xxl text-green">{{forksCount}}</view>
					<view class="margin-top-sm">
						<text class="cuIcon-fork"></text> 好友</view>
				</view>
			</view>
			<view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg radius">
				<view class="cu-item arrow">
					<navigator class="content" url="/pages/user/about" hover-class="none">
						<image src="/static/logo.png" class="png" mode="aspectFit"></image>
						<text class="text-grey">关于我们</text>
					</navigator>
				</view>
				<view class="cu-item arrow">
					<view class="content" @click="previewImage($event,['https://image.weilanwl.com/color2.0/zanCode.jpg'])" data-index="0">
						<text class="cuIcon-appreciatefill text-red"></text>
						<text class="text-grey">赞赏支持</text>
					</view>
				</view>
				<view class="cu-item arrow">
					<navigator class="content" url="/pages/user/log" hover-class="none">
						<text class="cuIcon-formfill text-green"></text>
						<text class="text-grey">更新日志</text>
					</navigator>
				</view>
				<view class="cu-item arrow">
					<button class="cu-btn content" open-type="feedback">
						<text class="cuIcon-writefill text-cyan"></text>
						<text class="text-grey">意见反馈</text>
					</button>
				</view>
				<view class="log-out-btn" @click="logout" v-if="this.loginInfo.hasLogin">
					<text class="cell-tit">退出登录</text>
				</view>
			</view>
			<view class="cu-tabbar-height"></view>
		</scroll-view>
	</view>
</template>

<script>
	import service from '../../common/service.js';
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState('base', ['appName', 'loginInfo'])
		},
		mixins: [service],
		data() {
			return {
				starCount: 0,
				forksCount: 0,
				visitTotal: 0,
			}
		},
		onLoad() {
			this.init();
		},
		methods: {
			init() {
				//强制登录
				if (this.loginInfo.forcedLogin) {
					this.loginCheck();
				}
			},
			loginCheck() {
				if (!this.loginInfo.hasLogin) {
					this.$util.goTo(this.$store.state.pages.login.path) //跳转到登录页面
				}
			}
		}
	}
</script>

<style>
	.ucenter-bg {
		background-image: url("~@/static/img/ucenter-bg.jpg");
		background-size: cover;
		height: 420rpx;
		display: flex;
		justify-content: center;
		padding-top: 10rpx;
		overflow: hidden;
		position: relative;
		flex-direction: column;
		align-items: center;
		color: #fff;
		font-weight: 300;
		text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
	}

	.ucenter-bg text {
		opacity: 0.8;
	}

	.ucenter-bg image {
		width: 200rpx;
		height: 200rpx;
	}

	.ucenter-bg .gif-wave {
		position: absolute;
		width: 100%;
		bottom: 0;
		left: 0;
		z-index: 99;
		mix-blend-mode: screen;
		height: 100rpx;
	}

	.log-out-btn {
		display: flex;
		align-items: baseline;
		padding: 80rpx $page-row-spacing;
		line-height: 80rpx;
		position: relative;
		background: #fff;
		justify-content: center;
		margin-top: 4rpx;
		color: red;
	}

	map,
	.mapBox {
		left: 0;
		z-index: 99;
		mix-blend-mode: screen;
		height: 100rpx;
	}

	map,
	.mapBox {
		width: 750rpx;
		height: 300rpx;
	}
</style>
